package cn.gcxy.javase.base;

import java.util.Comparator;

public class AccountComparator<T> implements Comparator<T> {

	private String type;
	
	public AccountComparator(String type){
		this.type=type;
	}
	@Override
	public int compare(T o1, T o2) {
		if(o1==o2){
			return 0;
		}
		
		Account a1=(Account)o1;
		Account a2=(Account)o2;
		if("no".equals(type)){
			return a1.getAccountNo().compareTo(a2.getAccountNo());
		}else if("name".equals(type)){
			return a1.getAccountName().compareTo(a2.getAccountName());
		}
		return 0;
	}

}
